package com.scommunity.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scommunity.admin.vo.UserQO;
import com.scommunity.domain.Owner;
import com.scommunity.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
@Transactional(rollbackFor = Exception.class)
public interface UserMapper extends BaseMapper<User> {
    @Insert("insert into sc_user values(#{userId},#{userName},#{userPassword},#{userStatus})")
    void add(User user);

    List<User> findPageInfoByCondition(UserQO userQO);

    @Select("select * from sc_user")
    List<User> findAll();

    void update1(User user);

    @Update("update sc_user set user_status = #{status} where user_id = (select user_id from sc_owner where owner_id = #{id})")
    void updateUserStatusById(String id, String status);

    @Select("select * from sc_owner where user_id = #{userId}")
    Owner getInfoByUserId(Long userId);

    @Select("select owner_id from sc_owner where user_id = #{userId}")
    Long getOwnerId(Long userId);
}
